package com.skit.jetpackstudy.databinding;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;

import com.skit.jetpackstudy.R;

/**
 * Author: shuike,
 * Email: shuike007@126.com,
 * Date: 2019/12/29.
 * PS:
 */
public class DataBindingActivity extends AppCompatActivity {
    DataBindingActivityBinding bindingActivityBinding;
    MyViewModel myViewModel;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        bindingActivityBinding = DataBindingUtil.setContentView(this, R.layout.data_binding_activity);
        myViewModel = ViewModelProviders.of(this).get(MyViewModel.class);
        bindingActivityBinding.setModel(myViewModel);
        bindingActivityBinding.setLifecycleOwner(this);//生命周期所有者
    }
}
